<template>
	<div>
		<div style="width: 100%;height: 20px;background-color: #ebedf0;"></div>
		<div style="padding: 20px;">
			<Row>
				<Col span="24" style="text-align: left;margin-top:15px;">
				<span>科目：</span>
				<RadioGroup v-model="subjectselect" type="button" @on-change="changeselect">
					<Radio v-for="item in subjectlist" :key="item.value" :label="item.value">{{item.label}}</Radio>
				</RadioGroup>
				</Col>
				<Spin size="large" fix v-if="subjectlistshow"></Spin>
			</Row>
		</div>
		<Row style="text-align: left;margin-top: 40px;">
			<span style="border-left: 5px solid #517EDB;font-size: 16px;"></span>
			<span style="font-size: 16px;font-weight: 800;margin-left: 41px;">评价结果汇总</span>
		</Row>
		<div style="padding: 10px 20px 20px 20px;">
			<div style="position: relative;">
				<Table border :columns="columns" :data="[{teacherNum:this.teacherNum,passNum:this.passNum,notPassNum:this.notPassNum,passRate:this.passRate,maxResult:this.maxResult,minResult:this.minResult,averageResults:this.averageResults}]"></Table>
			</div>
		</div>
		<Row style="text-align: left;margin-top: 40px;">
			<span style="border-left: 5px solid #517EDB;font-size: 16px;"></span>
			<span style="font-size: 16px;font-weight: 800;margin-left: 41px;">评价指标汇总</span>
		</Row>
		<div style="padding: 10px 20px 20px 20px;">
			<div style="position: relative;">
				<Table border :columns="columns1" :data="[{
					type:'最高分',
					threeRateResult:this.threeRateResultMax,
					transverseResult:this.transverseResultMax,
					longitudinalResult:this.longitudinalResultMax,
					classResult:this.classResultMax,
					teacherResult:this.teacherResultMax,
				},
				{
					type:'最低分',
					threeRateResult:this.threeRateResultMin,
					transverseResult:this.transverseResultMin,
					longitudinalResult:this.longitudinalResultMin,
					classResult:this.classResultMin,
					teacherResult:this.teacherResultMin,
					
				}]"></Table>
			</div>
			<!--<div style="position: relative;">
				<Table border :columns="columns2" :data="[{threeRateResultMin:this.threeRateResultMin,transverseResultMin:this.transverseResultMin,longitudinalResultMin:this.longitudinalResultMin,classResultMin:this.classResultMin,teacherResultMin:this.teacherResultMin}]"></Table>
			</div>-->
		</div>
		<Row style="text-align: left;margin-top: 40px;">
			<span style="border-left: 5px solid #517EDB;font-size: 16px;"></span>
			<span style="font-size: 16px;font-weight: 800;margin-left: 41px;">班级横、纵向情况汇总</span>
		</Row>
		<div style="padding: 20px;">
			<Row>
				<Col span="24" style="text-align: left;margin-top:15px;">
				<span>类型：</span>
				<RadioGroup v-model="typeselect" type="button" @on-change="typechangeselect">
					<Radio v-for="item in typelist" :key="item.value" :label="item.value">{{item.label}}</Radio>
				</RadioGroup>
				</Col>
			</Row>
			<Row>
				<Col span="24" style="text-align: left;margin-top:15px;">
				<span>层级：</span>
				<RadioGroup v-model="levelselect" type="button" @on-change="levelchangeselect">
					<Radio v-for="item in levellist" :key="item.value" :label="item.value">{{item.label}}</Radio>
				</RadioGroup>
				</Col>
			</Row>
			<div style="padding: 10px 20px 20px 20px; margin-top: 40px;">
				<div style="position: relative;">
					<Table border :columns="columns3" :data="data3"></Table>
				</div>
			</div>
		</div>

	</div>
</template>

<script>
	import api from "@/components/js/Apidomain.js"
	import { getsessionstorage } from '@/components/js/Localstorage'
	export default {
		data() {
			return {
				subjectlist: [],
				subjectlistshow: false, //科目选择列表的加载中显示隐藏
				subjectselect: "",
				teacherNum: "", //老师人数
				passNum: "", //通过人数
				notPassNum: "", //没通过人数
				passRate: "", //通过率
				maxResult: "", //最高分
				minResult: "", //最低分
				averageResults: "", //平均分
				threeRateResultMin: "", //三率得分最低
				threeRateResultMax: "", //三率得分最高
				transverseResultMin: "", //横向得分最低
				transverseResultMax: "", //横向得分最高
				longitudinalResultMin: "", //纵向得分最低
				longitudinalResultMax: "", //纵向得分最高
				classResultMin: "", //班级得分最低
				classResultMax: "", //班级得分最高
				teacherResultMin: "", //老师总分得分最低
				teacherResultMax: "", //老师总分得分最高
				typelist: [{
						value: "Transverse",
						label: "横向比较"
					},
					{
						value: "longitudinal",
						label: "纵向比较"
					}
				],
				typeselect: "",
				levelselect: "",
				levellist: [],
				columns: [
					{
						title: '参评教师',
						key: 'teacherNum',
						align: 'center',
					},
					{
						title: '达标教师',
						key: 'passNum',
						align: 'center',
					},
					{
						title: '未达标教师',
						key: 'notPassNum',
						align: 'center',
					},
					{
						title: '达标率',
						key: 'passRate',
						align: 'center',
					},
					{
						title: '最高分',
						key: 'maxResult',
						align: 'center',
					},
					{
						title: '最低分',
						key: 'minResult',
						align: 'center',
					},
					{
						title: '平均分',
						key: 'averageResults',
						align: 'center',
					},
				],
				columns1: [{

						title: '类型',
						key: 'type',
						align: 'center',
					},
					{
						title: '三率得分',
						key:'threeRateResult',
						align: 'center',
					},
					{
						title: '横向得分',
						key: 'transverseResult',
						align: 'center',
					},
					{
						title: '纵向得分',
						key: 'longitudinalResult',
						align: 'center',
					},
					{
						title: '班级得分',
						key: 'classResult',
						align: 'center',
					},
					{
						title: '总得分',
						key: 'teacherResult',
						align: 'center',
					}

				],
//				columns2: [{
//						title: '三率得分最低',
//						key: 'threeRateResultMin',
//						align: 'center',
//					},
//					{
//						title: '横向得分最低',
//						key: 'transverseResultMin',
//						align: 'center',
//					},
//					{
//						title: '纵向得分最低',
//						key: 'longitudinalResultMin',
//						align: 'center',
//					},
//					{
//						title: '班级得分最低',
//						key: 'classResultMin',
//						align: 'center',
//					},
//					{
//						title: '总分得分最低',
//						key: 'teacherResultMin',
//						align: 'center',
//					}
//
//				],
				columns3: [
					{
						title: '类别',
						key: 'type',
						align: 'center',
					},
					{
						title: '班级',
						key: 'className',
						align: 'center',
					},
					{
						title: '人数',
						key: 'number',
						align: 'center',
					},
					{
						title: '类别',
						key: 'type2',
						align: 'center',
					},
					{
						title: '班级',
						key: 'className2',
						align: 'center',
					},
					{
						title: '人数',
						key: 'number2',
						align: 'center',
					},

				],
				
				data3: []

			}
		},
		created() {
			this.getsubjectlist()
			this.typeselect = this.typelist[0].value;

		},
		methods: {
			changeselect: function() {
				//				//console.log(this.subjectselect)
				this.getTeacherResultSummary();
				this.getTeacherIndicatorsSummary();
				this.getClassTransverseAndlongitudinalSummary();

			},
			typechangeselect: function() {
				this.getLevel()
			},
			levelchangeselect: function() {
				this.getClassTransverseAndlongitudinalSummary()
			},
			getsubjectlist: function() {
				this.subjectlistshow = true;
				let sessionroleid = getsessionstorage('roleid');
				let sessionperformId = getsessionstorage('performId');
				let sessiongradeId = getsessionstorage('gradeId');
				var self = this;
				let url = api.apidomain + '/tqes/web/quaPerformance/getSubjectByGrade';
				this.$http.post(url, {
						"performId": sessionperformId,
						"roleId": sessionroleid,
						"gradeId": sessiongradeId
					}).then(function(response) {
						if(response.data.success == true) {

							//						////console.log(response.data.data)
							self.subjectlist = response.data.data
							if(self.subjectlist.length != 0) {
								self.subjectselect = self.subjectlist[0].value;
							}
							self.getTeacherResultSummary()
							self.getTeacherIndicatorsSummary()
							//							self.getClassTransverseAndlongitudinalSummary()
							self.getLevel()
							self.subjectlistshow = false;
						} else if(response.data.success == false) {
							self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
							self.subjectlistshow = false;
						}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00188',
							duration: 10,
							closable: true
						});
						self.subjectlistshow = false;
					});
			},
			getTeacherResultSummary: function() {
				let sessionroleid = getsessionstorage('roleid');
				let sessionperformId = getsessionstorage('performId');
				var self = this;
				let url = api.apidomain + '/tqes/web/quaTeacherResults/TeacherResultSummary'
				this.$http.post(url, {
						"performId": sessionperformId,
						"roleId": sessionroleid,
						"adName": self.subjectselect
					}).then(function(response) {
						if(response.data.success == true) {
							//							console.log(response.data)

							self.teacherNum = response.data.data.teacherNum
							self.passNum = response.data.data.passNum
							self.notPassNum = response.data.data.notPassNum
							self.passRate = response.data.data.passRate
							self.maxResult = response.data.data.maxResult
							self.minResult = response.data.data.minResult
							self.averageResults = response.data.data.averageResults
						} else if(response.data.success == false) {
							self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
						}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00188',
							duration: 10,
							closable: true
						});
						self.subjectlistshow = false;
					});
			},
			getTeacherIndicatorsSummary: function() {
				let sessionroleid = getsessionstorage('roleid');
				let sessionperformId = getsessionstorage('performId');
				var self = this;
				let url = api.apidomain + '/tqes/web/quaTeacherResults/TeacherIndicatorsSummary'
				this.$http.post(url, {
						"performId": sessionperformId,
						"roleId": sessionroleid,
						"adName": self.subjectselect
					}).then(function(response) {
						if(response.data.success == true) {
							//							console.log(response.data)

							self.threeRateResultMin = response.data.data.threeRateResultMin
							self.threeRateResultMax = response.data.data.threeRateResultMax
							self.transverseResultMin = response.data.data.transverseResultMin
							self.transverseResultMax = response.data.data.transverseResultMax
							self.longitudinalResultMin = response.data.data.longitudinalResultMin
							self.longitudinalResultMax = response.data.data.longitudinalResultMax
							self.classResultMin = response.data.data.classResultMin
							self.classResultMax = response.data.data.classResultMax
							self.teacherResultMin = response.data.data.teacherResultMin
							self.teacherResultMax = response.data.data.teacherResultMax
						} else if(response.data.success == false) {
							self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
						}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00188',
							duration: 10,
							closable: true
						});
						self.subjectlistshow = false;
					});
			},
			getLevel: function() {
				var self = this;
				let url = api.apidomain + '/tqes/web/quaHorizontalChange/getLevel'
				this.$http.post(url, {
						"type": this.typeselect
					}).then(function(response) {
						if(response.data.success == true) {
							//							console.log(response.data)
							self.levellist = response.data.data
							if(self.levellist.length != 0) {
								self.levelselect = self.levellist[0].value;
							}
							self.getClassTransverseAndlongitudinalSummary()
						} else if(response.data.success == false) {
							self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
						}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00188',
							duration: 10,
							closable: true
						});
						self.subjectlistshow = false;
					});
			},
			getClassTransverseAndlongitudinalSummary: function() {
				let sessionroleid = getsessionstorage('roleid');
				let sessionperformId = getsessionstorage('performId');
				var self = this;
				let url = api.apidomain + '/tqes/web/quaHorizontalChange/ClassTransverseAndlongitudinalSummary'
				this.$http.post(url, {
						"performId": sessionperformId,
						"subject": self.subjectselect,
						"roleId": sessionroleid,
						"level": self.levelselect,
						"type": self.typeselect
					}).then(function(response) {
						if(response.data.success == true) {

							self.data3 = response.data.data
							console.log(response.data.data)
						} else if(response.data.success == false) {
							self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
						}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00188',
							duration: 10,
							closable: true
						});
						self.subjectlistshow = false;
					});
			}

		}
	}
</script>

<style>

</style>